package com.testmanager.testmananger.quantitative.mapper;

import com.testmanager.testmananger.quantitative.constants.BugStatus;

import com.testmanager.testmananger.quantitative.domain.BugInfoEntity;
import com.testmanager.testmananger.quantitative.dto.BugInfoDto;
import com.testmanager.testmananger.quantitative.dto.WorkerDto;

public class BugInfoMapper {

    public static BugInfoDto toBugInfoDto(BugInfoEntity bugInfoEntity, WorkerDto repairer,WorkerDto submitter){
        BugInfoDto bugInfoDto = new BugInfoDto();
        return bugInfoDto.setId(bugInfoEntity.getId())
                .setDescribe(bugInfoEntity.getDescribe())
                .setStatus(bugInfoEntity.getStatus().getValue())
                .setBugNo(bugInfoEntity.getBugNo())
                .setRepairer(repairer)
                .setSubmiteer(submitter)
                .setBugLevel(bugInfoEntity.getBugLevel())
                .setBugUnfixedCount(bugInfoEntity.getBugUnfixedCount());
    }

    public static BugInfoEntity toBugInfoEntity(BugInfoEntity bugInfoEntity ,BugInfoDto bugInfoDto,long iterationId){
            return bugInfoEntity.setId(bugInfoDto.getId())
                    .setDescribe(bugInfoDto.getDescribe())
                    .setStatus(BugStatus.getValueOf(bugInfoDto.getStatus()))
                    .setIterationId(iterationId)
                    .setBugUnfixedCount(bugInfoDto.getBugUnfixedCount())
                    .setBugLevel(bugInfoDto.getBugLevel())
                    .setBugNo(bugInfoDto.getBugNo());
    }



}
